/**
 * FileName: FileDecryptTask.java
 * @Description: TODO(用一句话描述该文件做什么)
 * All rights Reserved, Designed By 21winmess
 * Copyright: Copyright(C) 2010-2011 
 * Company 21winmess DaLian LTD.
 * @author: Matrix xu
 * @version V2.0
 * Createdate: 2012-11-28 下午6:04:06
 *
 * Modification History:
 * Date Author Version Discription
 * -----------------------------------------------------------------------------------
 * 2012-11-28 Qute_Android2.0
 * Why & What is modified: <修改原因描述>
 */
package com.me.safebox.service;

import java.util.concurrent.Callable;

import android.provider.UserDictionary.Words;
import android.util.Log;

import com.me.safebox.data.SafeFile;
import com.me.safebox.data.SafeboxDao;
import com.me.safebox.utils.EncryptWorker;
import com.me.safebox.utils.FileHelper;

/**
 * @ClassName: FileDecryptTask
 * @Description:TODO(这里用一句话描述这个类的作用)
 * @author: Matrix
 * @date: 2012-11-28 下午6:04:06
 * 
 */
public class FileDecryptTask implements Callable<IFuture> {

	
	
	private SafeFile safeFile = null;

	public FileDecryptTask(SafeFile safeFile) {
		this.safeFile = safeFile;
	}

	@Override
	public DecryFuture call() throws Exception {
		DecryFuture decryFuture = new DecryFuture();
		String filePath = FileHelper.moveFile(safeFile.encrptFilePath, safeFile.sourceDir, safeFile.sourceName);
		Log.i("filetask", "move file:" + filePath);
		if (filePath != null) {// 移动成功
			boolean isDecryptSuccess = EncryptWorker.decryptFile(filePath, EncryptWorker.HEAD_LENGTH);// 直接对该文件解密,并重写该文件格式
			Log.i("filetask", "decrypt file" + isDecryptSuccess);
			decryFuture.deletePermisson = isDecryptSuccess;
			decryFuture.fileId = safeFile.id;
		}
		return decryFuture;
	}
}
